<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
{#    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" rel="stylesheet">#}
{#    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.1/font/bootstrap-icons.min.css" rel="stylesheet">#}
{#    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>#}
{#    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js"></script>#}

    <link href="{{ url_for('static',filename='bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
    <link href="{{ url_for('static',filename='bootstrap/bootstrap-icons-1.11.1/bootstrap-icons.min.css') }}" rel="stylesheet">
    <script src="{{ url_for('static',filename='jquery/jquery-3.7.1.min.js') }}"></script>
    <script src="{{ url_for('static',filename='bootstrap/js/bootstrap.bundle.min.js') }}"></script>
    <style>
        :root {
            --primary-color: #2E7D32;
            --secondary-color: #81C784;
            --accent-color: #DCEDC8;
            --text-color: #212121;
            --light-text: #757575;
        }

        body {
            background-color: #F5F5F5;
            background-size: cover;
            background-position: center;
            background-blend-mode: overlay;
            min-height: 100vh;
            color: var(--text-color);
            display: flex;
            flex-direction: column;
            margin: 0;
            padding: 0;
        }

        .header-container {
            width: 100%;
            background: linear-gradient(90deg, #1B5E20, #2E7D32, #388E3C);
            box-shadow: 0 3px 15px rgba(0, 0, 0, 0.3);
            padding: 0;
            margin: 0;
            position: relative;
            z-index: 100;
            text-align: center;
        }

        .header-content {
            max-width: 1400px; /* 增加最大宽度 */
            margin: 0 auto;
            padding: 1.2rem 2rem; /* 增加垂直内边距 */
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .title-container {
            display: flex;
            align-items: center;
            margin-bottom: 0.5rem;
        }

        .header-logo {
            height: 90px; /* 增加logo尺寸 */
            width: 90px; /* 增加logo尺寸 */
            margin-right: 1.5rem; /* 增加右侧间距 */
            background-color: rgba(255, 255, 255, 0.95);
            padding: 5px;
            border-radius: 50%;
            object-fit: contain;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); /* 添加阴影效果 */
        }

        .header-title {
            color: #FFFFFF;
            font-size: 2.2rem; /* 增大字体 */
            font-weight: 700;
            margin: 0;
            text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.4); /* 增强文字阴影 */
            letter-spacing: 1px; /* 增加字母间距 */
        }

        .header-slogan {
            color: #E8F5E9;
            font-size: 1.3rem; /* 增大字体 */
            font-weight: 400;
            margin: 0;
            letter-spacing: 2px; /* 增加字母间距 */
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3); /* 增强文字阴影 */
        }

        .main-container {
            width: 100%;
            max-width: 1200px;
            margin: 2rem auto;
            padding: 0 2rem;
            flex-grow: 1;
            display: flex;
            align-items: center;
        }

        .content-box {
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            padding: 2rem;
        }

        .login-box {
            /* 登录窗口不设置固定高度，让它根据内容自然展开 */
            overflow-y: auto;
        }

        .notice-box {
            /* 设置公告窗口的高度与登录窗口保持一致 */
            height: 520px;
            overflow-y: auto;
        }

        .system-notice {
            display: flex;
            flex-direction: column;
        }

        .notice-header {
            display: flex;
            align-items: center;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid var(--secondary-color);
        }

        .notice-icon {
            font-size: 1.5rem;
            color: var(--primary-color);
            margin-right: 0.5rem;
        }

        .notice-title {
            font-size: 1.3rem;
            color: var(--primary-color);
            font-weight: 600;
            margin: 0;
        }

        .notice-list {
            flex-grow: 1;
            overflow-y: auto;
            padding-right: 0.5rem;
            margin-bottom: 0;
        }

        .notice-item {
            padding: 0.75rem;
            margin-bottom: 1rem;
            border-left: 4px solid var(--secondary-color);
            background-color: var(--accent-color);
            border-radius: 0 4px 4px 0;
        }

        .notice-item:last-child {
            margin-bottom: 0;
        }

        .notice-item-title {
            font-weight: 600;
            margin-bottom: 0.5rem;
            color: var(--primary-color);
        }

        .notice-item-date {
            font-size: 0.85rem;
            color: var(--light-text);
            margin-bottom: 0.5rem;
        }

        .notice-item-content {
            font-size: 0.95rem;
        }

        .login-container {
            display: flex;
            flex-direction: column;
        }

        .logo-container {
            text-align: center;
            margin-bottom: 1rem;
        }

        .logo {
            width: 80px;
            height: 80px;
            object-fit: contain;
        }

        h1 {
            color: var(--primary-color);
            font-weight: 700;
            margin-bottom: 1rem;
            text-align: center;
            font-size: 1.8rem;
        }

        .form-control:focus {
            border-color: var(--secondary-color);
            box-shadow: 0 0 0 0.25rem rgba(129, 199, 132, 0.25);
        }

        .btn-primary {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
            width: 100%;
            padding: 0.5rem;
            font-weight: 600;
            margin-top: 0.75rem;
            transition: all 0.3s ease;
        }

        .btn-primary:hover, .btn-primary:focus {
            background-color: #1B5E20;
            border-color: #1B5E20;
            transform: translateY(-2px);
        }

        .login-footer {
            margin-top: 0.75rem;
            text-align: center;
            font-size: 0.9rem;
            color: var(--light-text);
        }

        .register-link {
            margin-top: 0.75rem;
            text-align: center;
        }

        .register-link a {
            color: var(--primary-color);
            text-decoration: none;
            font-weight: 500;
        }

        .register-link a:hover {
            text-decoration: underline;
        }

        .contact-info {
            margin-top: 1rem;
            text-align: center;
            font-size: 0.8rem;
            color: var(--light-text);
            border-top: 1px solid #eee;
            padding-top: 0.75rem;
        }

        .input-group-text {
            background-color: var(--accent-color);
            border-color: #ced4da;
            color: var(--primary-color);
        }

        .animated-bg {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            background: linear-gradient(120deg, #e0f7fa, #e8f5e9, #f1f8e9);
            background-size: 300% 300%;
            animation: gradientShift 15s ease infinite;
        }

        @keyframes gradientShift {
            0% {background-position: 0% 50%;}
            50% {background-position: 100% 50%;}
            100% {background-position: 0% 50%;}
        }

        .row {
            --bs-gutter-x: 3rem; /* 增加列之间的间距 */
        }

        @media (max-width: 767.98px) {
            .row > div:first-child {
                margin-bottom: 2rem;
            }

            .header-title {
                font-size: 1.6rem;
            }

            .header-slogan {
                font-size: 1rem;
                letter-spacing: 1px;
            }

            .title-container {
                flex-direction: column;
                margin-bottom: 0.5rem;
            }

            .header-logo {
                margin-right: 0;
                margin-bottom: 0.5rem;
                height: 50px;
                width: 50px;
            }

            .main-container {
                margin-top: 1rem;
            }
        }
    </style>
</head>
<body>
    <div class="animated-bg"></div>

    <!-- 修改后的标题栏 -->
    <header class="header-container">
        <div class="header-content">
            <div class="title-container">
                <img src="{{ url_for('static', filename='images/logo_1.png') }}" alt="林业3PG模型系统" class="header-logo">
                <h1 class="header-title">林序3PG模型可视化系统</h1>
            </div>
            <p class="header-slogan">精算生态&nbsp;&nbsp;智绘林颜</p>
        </div>
    </header>

    <div class="container main-container">
        <div class="row">
            <!-- 左侧 - 系统公告区域 -->
            <div class="col-md-6">
                <div class="content-box notice-box system-notice">
                    <div class="notice-header">
                        <i class="bi bi-megaphone-fill notice-icon"></i>
                        <h2 class="notice-title">系统公告</h2>
                    </div>
                    <div class="notice-list">
                        <div class="notice-item">
                            <div class="notice-item-title">系统更新：林序v2.0上线</div>
                            <div class="notice-item-date">2025年4月5日</div>
                            <div class="notice-item-content">
                                林序3PG模型可视化系统已更新至v2.0版本。此次更新增加了敏感新分析与参数优化功能，并在模型计算项目的输出结果模块后添加了精度检验模块。
                            </div>
                        </div>
                        <div class="notice-item">
                            <div class="notice-item-title">新增树种参数库</div>
                            <div class="notice-item-date">2025年3月15日</div>
                            <div class="notice-item-content">
                                系统参数库已更新，新增3个常见树种和3个站点气候数据项，您可以在模拟计算项目中直接作为输入使用。
                            </div>
                        </div>
                        <div class="notice-item">
                            <div class="notice-item-title">用户手册更新</div>
                            <div class="notice-item-date">2025年2月20日</div>
                            <div class="notice-item-content">
                                我们已更新系统用户手册，新增了详细的操作指南。您可以在登录后的"帮助"模块查看最新版本的用户手册。
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 右侧 - 登录表单 -->
            <div class="col-md-6">
                <div class="content-box login-box login-container">
                    <div class="logo-container">
{#                        <img src="/api/placeholder/80/80" alt="" class="logo">#}
                    </div>

                    <h1>登录</h1>

                    <form id="loginForm">
                        <div class="mb-2">
                            <div class="input-group">
                                <span class="input-group-text"><i class="bi bi-envelope-fill"></i></span>
                                <input type="email" class="form-control" id="email" placeholder="请输入邮箱" required>
                            </div>
                        </div>

                        <div class="mb-2" style="margin-top:15px;">
                            <div class="input-group">
                                <span class="input-group-text"><i class="bi bi-lock-fill"></i></span>
                                <input type="password" class="form-control" id="password" placeholder="请输入密码" required>
                            </div>
                        </div>

                        <div class="mb-2 form-check" style="margin-top:15px;">
                            <input type="checkbox" class="form-check-input" id="rememberMe">
                            <label id="online" class="form-check-label" for="rememberMe">记住密码</label>
                        </div>

                        <button type="submit" class="btn btn-primary">登 录</button>
                    </form>

                    <div class="register-link">
                        <p class="mb-0">还没有账号？<a href="{{ url_for('auth.register') }}">立即注册</a></p>
                    </div>

                    <div class="login-footer">
                        <p class="mb-0">3PG模型是一种基于生理机理的森林生长预测工具。</p>
                    </div>

                    <div class="contact-info">
                        <p class="mb-1">联系我们</p>
                        <p class="mb-1">邮箱：finmzhao@163.com</p>
                        <p class="mb-1">电话：+86 185 1003 0270</p>
{#                        <p class="mb-0">© 2025 版权所有</p>#}
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        /**
         * 显示简单提示信息
         * @param {string} message - 提示内容
         * @param {string} type - 类型：'success'(正确), 'warning'(警告), 'error'(错误)
         * @param {number} duration - 显示时间（毫秒）
         */
        function showMessage(message, type = 'success', duration = 2000) {
          // 设置颜色和图标
          let color, icon;
          switch(type) {
            case 'success':
              color = '#4CAF50';
              icon = '✓';
              break;
            case 'warning':
              color = '#FF9800';
              icon = '⚠';
              break;
            case 'error':
              color = '#F44336';
              icon = '✗';
              break;
            default:
              color = '#4CAF50';
              icon = '✓';
          }

          // 创建toast元素
          const toast = $(`
            <div style="
              margin-bottom: 10px;
              padding: 10px 15px;
              background-color: ${color};
              color: white;
              border-radius: 4px;
              box-shadow: 0 2px 5px rgba(0,0,0,0.2);
              display: flex;
              align-items: center;
              opacity: 0;
              transition: opacity 0.3s ease;
            ">
              <span style="margin-right: 10px; font-weight: bold;">${icon}</span>
              <span>${message}</span>
            </div>
          `).appendTo('#simple-toast');

          // 显示元素
          setTimeout(() => toast.css('opacity', 1), 10);

          // 设置自动隐藏
          setTimeout(() => {
            toast.css('opacity', 0);
            setTimeout(() => toast.remove(), 300);
          }, duration);
        }

        // 使用示例:
        // 正确提示: showMessage("操作成功", "success");
        // 警告提示: showMessage("请注意", "warning");
        // 错误提示: showMessage("操作失败", "error");
        $(document).ready(function() {
            if (!$('#simple-toast').length) {
                $('body').append('<div id="simple-toast" style="position:fixed; top:24%; left:50%; transform:translate(-50%, -24%); z-index:9999;"></div>');
            }
            // 登录表单提交
            $("#loginForm").submit(function(e) {
                e.preventDefault();

                // 获取表单数据
                const email = $("#email").val();
                const password = $("#password").val();
                const online = $("#online").val();

                // 这里添加验证逻辑
                if(!email || !password) {
                    alert("请填写完整登录信息");
                    return;
                }

                $.ajax({
                    url:'{{ url_for('auth.login') }}',
                    type:"POST",
                    contentType:'application/json',
                    data:JSON.stringify({
                        email:email,
                        password:password,
                        online:online
                    }),
                    success:function(response){
                        if(response.success){
                            showMessage(response.message,"success");
                            setTimeout(function() {
                                window.location.href = "{{ url_for('func.index') }}";
                            }, 1300);
                        }else{
                            showMessage(response.message,"error");
                        }
                    },
                    error:function (xhr,status,error){
                        showMessage("服务出错：" + error,"error");
                    }
                })

            });
        });

    </script>
</body>
</html>